import React, { useState } from 'react'
import { useEffect } from 'react'

export default function App() {
  let [opacity, setOpacity] = useState([{
    id:'1',
    name: '张麻子'
  },{
    id:'2',
    name: '李四'
  },{
    id:'3',
    name: '王五'
  }]);

  useEffect(() => {
    console.log('组件被重新渲染了');
  }, [person]);

  const addPerson = () => {
    setPerson([...person, {id:Date.now(), name: '♥♥♥'}]);
  }
  
  return (
    <div>
    <button onClick={addPerson}>添加数据</button>
    <ul>
      {
        person.map(item => {
          return <li key={item.id}>{item.name}</li>
        })
      }
    </ul>
    </div>
  )
}
 